package com.shire.shire_interface.service.timeline;

import com.shire.shire_interface.dao.timeline.WxTimelineFileDao;
import com.shire.shire_interface.model.timeline.WxTimelineFile;
import com.shire.shire_interface.model.timeline.WxTimelineFileExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WxTimelineFileService {
    @Resource
    private WxTimelineFileDao timelineFileDao;

    public List<String> checkIdExist(List<String> ids){
        WxTimelineFileExample example = new WxTimelineFileExample();
        example.createCriteria().andMidIn(ids);
        List<WxTimelineFile> files = timelineFileDao.selectByExample(example);

        for (WxTimelineFile file : files) {
            if (ids.contains(file.getMid())){
                ids.remove(file.getMid());
            }
        }
        return ids;
    }

    public WxTimelineFile getTimelineFileById(String mid){
        return timelineFileDao.selectByPrimaryKey(mid);
    }

    public int insertWxTimelinefile(WxTimelineFile timelineFile){
        return timelineFileDao.insert(timelineFile);
    }
    public int updateWxTimelinefile(WxTimelineFile timelineFile){
        return timelineFileDao.updateByPrimaryKey(timelineFile);
    }

    public List<WxTimelineFile> getFilesByIdList(List<String> idList){
        WxTimelineFileExample example = new WxTimelineFileExample();
        example.createCriteria().andMidIn(idList);
        return timelineFileDao.selectByExample(example);
    }
}
